﻿<Window x:Class="Brjnk.GpxExplorer.UI.GCBrowserWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:l="clr-namespace:Brjnk.GpxExplorer.Localization"
        xmlns:my="clr-namespace:Brjnk.GpxExplorer.UI"
        Title="{l:Loc titleGCBrowser}"
        Width="525"
        Height="350"
        Loaded="Window_Loaded">
    <TabControl ItemsSource="{Binding Tabs}">
        <TabControl.ItemContainerStyle>
            <Style TargetType="{x:Type TabItem}">
                <Setter Property="HeaderTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Width="75"
                                           Text="{Binding Title}"
                                           TextTrimming="CharacterEllipsis"
                                           TextWrapping="NoWrap" />
                                <Button MinWidth="0" Command="{Binding CloseTabCommand}">
                                    <Image Width="16" Source="/Resources/Icons/close.png" />
                                </Button>
                            </StackPanel>
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="ContentTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="*" />
                                </Grid.RowDefinitions>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="15" />
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>
                                    <Menu Grid.Column="0">
                                        <MenuItem Command="NavigationCommands.BrowseBack"
                                                  CommandTarget="{Binding WebBrowserControl}"
                                                  Header="{l:Loc browserBack}">
                                            <MenuItem.Icon>
                                                <Image Width="16" Source="/Resources/Icons/Back.png" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Command="NavigationCommands.BrowseForward"
                                                  CommandTarget="{Binding WebBrowserControl}"
                                                  Header="{l:Loc browserForward}">
                                            <MenuItem.Icon>
                                                <Image Width="16" Source="/Resources/Icons/Forward.png" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Command="NavigationCommands.Refresh"
                                                  CommandTarget="{Binding WebBrowserControl}"
                                                  Header="{l:Loc browserRefresh}">
                                            <MenuItem.Icon>
                                                <Image Width="16" Source="/Resources/Icons/Refresh.png" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Command="{Binding Parent.AddTabCommand}" Header="{l:Loc browserNewTab}">
                                            <MenuItem.Icon>
                                                <Image Width="16" Source="/Resources/Icons/NewTab.png" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                    </Menu>
                                    <TextBox Grid.Column="1"
                                             KeyDown="TextBox_KeyDown"
                                             Text="{Binding Location,
                                                            Mode=TwoWay,
                                                            UpdateSourceTrigger=PropertyChanged}"
                                             TextWrapping="NoWrap" />

                                    <ContentControl Grid.Column="2"
                                                    Width="15"
                                                    Height="15"
                                                    ContentTemplate="{StaticResource WorkingAnimation}"
                                                    Visibility="{Binding Working,
                                                                         Converter={StaticResource BooleanToVisibilityConverter}}" />
                                    <my:GoToCoordinatesPanel Grid.Column="3"
                                                             ButtonAddPushpin="false"
                                                             ButtonAddPushpinAndGoTo="true"
                                                             ButtonAddPushpinAndGoToBigZoom="false"
                                                             ButtonCopyToClipboard="true"
                                                             ButtonCreateWaypoint="false"
                                                             ButtonGoTo="false"
                                                             ButtonGoToBigZoom="false"
                                                             GpsCoordinates="{Binding Result.Geocache.Coordinates}">
                                        <my:GoToCoordinatesPanel.Style>
                                            <Style TargetType="my:GoToCoordinatesPanel">
                                                <Setter Property="Visibility" Value="Collapsed" />
                                                <Style.Triggers>
                                                    <DataTrigger Binding="{Binding Result.Type}" Value="Ok">
                                                        <Setter Property="Visibility" Value="Visible" />
                                                    </DataTrigger>
                                                </Style.Triggers>
                                            </Style>
                                        </my:GoToCoordinatesPanel.Style>
                                    </my:GoToCoordinatesPanel>
                                    <Menu Grid.Column="4" HorizontalAlignment="Right">
                                        <MenuItem Command="{Binding ImportCommand}" Header="Import" />
                                        <MenuItem Command="{Binding UpdateCommand}" Header="Update" />
                                        <MenuItem Command="{Binding Parent.ImportLoadedCommand}" Header="ImportAll" />
                                    </Menu>
                                    <TextBlock Grid.Row="1"
                                               Grid.ColumnSpan="4"
                                               Background="SandyBrown"
                                               FontSize="15"
                                               FontWeight="Bold"
                                               Text="{l:Loc browserNotLoggedIn}"
                                               Visibility="{Binding NotLoggedIn,
                                                                    Converter={StaticResource BooleanToVisibilityConverter}}" />
                                    <TextBlock Grid.Row="2"
                                               Grid.ColumnSpan="4"
                                               Background="Pink"
                                               FontSize="15"
                                               FontWeight="Bold"
                                               Text="{l:Loc browserReadFailed}"
                                               Visibility="{Binding Failed,
                                                                    Converter={StaticResource BooleanToVisibilityConverter}}" />
                                </Grid>
                                <ContentControl Grid.Row="1" Content="{Binding WebBrowserControl}" />
                            </Grid>
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="IsSelected" Value="{Binding Path=IsActive}" />
            </Style>
        </TabControl.ItemContainerStyle>
    </TabControl>
</Window>